|
Notes & Mini-Essays |
|
|
|
|
> Writing / Notes & Mini-Essays / First Git Steps | ||||||
First Git Steps06-04-2025 IntroductionWhat is git?I admit I had made this note for a public of mostly computer scientists so I found it fair to add this little introduction for people who reasonably have never heard of this, on here (here being neocities). Note that this whole... note, is uncomplete, aimed to people used to working with the terminal (habit which is surprisingly easy to get into I swear) and ultimately just boils down to a quick cheatsheet to start using it on your own. Resources
Here is the official Git book, a comprehensive guide. I don't cover in here the download process; in Linux you should be installing it through a package management tool, while on windows you can get the exe from the official git website, here. SetupConfiguration
The first thing you should do after installing git is to insert your name and email address in the git configuration. This is important because these will be your signatures every time you make a commit.
You should also configurate what your default text editor is: on Linux you need only write the name of the command, as such:
The manual is your best friend. Please consult it.
Terminal tab completion, too, is your best friend. Circle most used commands by the up and down arrows; auto-complete commands (such as file names) by typing the first letters, and then pressing tab.
It is generally regarded as good and sensible practice to change the name of your initial branch. The historical name has been
You can see the full config up to now with the command First commands and first project Source
Here's how to create one. First, you should navigate (with your terminal) to a folder which will be the workspace of your project. Good practice would be to organize it inside another folder which holds your other projects, or related projects/resources, but that's your choice. If you are on
This reminds me, I should create a little Linux terminal guide. Although, many people have done this already, quite better than I could right now, so I suggest following theirs for the time being.
Hidden Folders; note: every folder which starts with a dot is "hidden": to make it show on the terminal with the ls command, use the flag -a
Then you can create files either with your GUI of choice or by commands such as
Then run the command git add *.c ,
Commit Messages; See here to get an idea of what a good commit message looks like. Starting to commit well early is a good habit. It will not only make others aware that you know what you are doing, but it will be extremely helpful either to yourself or others, when going back at the code. If you write coincise commit messages from the get go, you won't have to wonder what the hell this or that update was about in a few months. Cloning a repository
You can clone a repository with the command
!Git vs GitHub!: Git and Github are two different and separate things. Think Git as a software which can help you coordinate between versions of a software, and GitHub as a web server/platform where software can be stored, hosted, and shared in. GitHub relies on Git for version control.
Optional step: if you don't have one yet, then go create one, by signing up on github.com if you haven't. Github is a good place to share your code, to get feedback on it, and to gradually build a code portfolio. Github is arguably the most used, but know, though, that there are more places like github which allow you to host or self-host your code in a more personal and private way; for example, Gitea or others. At the time of writing, I'm not versed enough in their use to say more about them, though.
Optional step: Here is how to set up GitHub Authentication with SSH (Secure Shell Protocol); with it, you will be able to work on your private repository from your terminal, as the protocol authenticates you with your GitHub account. Related: |
|||||||
| website inspiration from: Reti Medievali, 2000 |